<% include head.ejs %>
<body>
<div class="wp">
    <header class="t-header">
        <div class="topbar">
            <a href="/comm/commInfo" class="gobakA fl">
                <i class="icon-angle-left"></i>
            </a>
            <span>佣金明细</span>
        </div><!-- topbar end -->
    </header>

    <div class="myYJinfoNAV">
        <ul class="clearfix">
            <li>
                <a id="month" class="active" href="#">本月</a>
            </li>
            <li>
                <a id="year" href="#">本年以内</a>
            </li>
            <li>
                <a id="all" href="#">全部</a>
            </li>
        </ul>
    </div>

    <div class="myYJlistbox">
        <ul id="detail">
            <li class="tit clearfix">
                <dl><span>创建时间</span></dl>
                <dl><span>佣金比例</span></dl>
                <dl><span>佣金</span></dl>
                <dl><span>成交金额</span></dl>
            </li>
            <% for(var i in commDetail){%>
            <li class="clearfix">
                <dl>
                            <span>
                                <font class="data"><%= commDetail[i].comm_time%></font>
                            </span>
                </dl>
                <dl>
                    <span><%= commDetail[i].discount%>%</span>
                </dl>
                <dl><span><%= commDetail[i].comm_value/100%></span></dl>
                <dl><span><%= commDetail[i].pay_price/100%></span></dl>
            </li>
            <% }%>
        </ul>
    </div>

</div>
<script>
    $('#month').click(function () {
        $('#month').addClass('active');
        $('#year').removeClass('active');
        $('#all').removeClass('active');
        getDetail(1);
    });

    $('#year').click(function () {
        $('#month').removeClass('active');
        $('#year').addClass('active');
        $('#all').removeClass('active');
        getDetail(2);
    });

    $('#all').click(function () {
        $('#month').removeClass('active');
        $('#year').removeClass('active');
        $('#all').addClass('active');
        getDetail(3);
    });

    function getDetail(sign) {
        $('#detail li').remove();
        var html = "<li class='tit clearfix'>";
        html += "<dl><span>创建时间</span></dl>";
        html += "<dl><span>佣金比例</span></dl>";
        html += "<dl><span>佣金</span></dl>";
        html += "<dl><span>成交金额</span></dl>";
        html += "</li>";
        $.get('/comm/getCommDetail',{sign:sign},function (data) {
            var comm = JSON.parse(data);
            for(var i in comm){
                html += "<li class='clearfix'>";
                html += "<dl>";
                html += "<span>";
                html += "<font class='data'>"+comm[i].comm_time+"</font>";
                html += "</span>";
                html += "</dl>";
                html += "<dl><span>"+comm[i].discount+"%</span></dl>";
                html += "<dl><span>"+comm[i].comm_value/100+"</span></dl>";
                html += "<dl><span>"+comm[i].pay_price/100+"</span></dl>";
                html += "</li>";
            }
            $('#detail').append(html);
        });
    }
</script>
</body>